package com.example.mapdata.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.mapdata.dao.AreaDao;
import com.example.mapdata.entity.Area;
import com.example.mapdata.service.AreaService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Area)表服务实现类
 *
 * @author makejava
 * @since 2024-09-20 09:31:48
 */
@Service("areaService")
public class AreaServiceImpl implements AreaService {
    @Resource
    private AreaDao areaDao;

    /**
     * 根据城市编号获取所有的区县信息
     *
     * @param cityCode
     * @return
     */
    @Override
    public List<Area> getAreaByCityCode(String cityCode) {
        QueryWrapper qw = new QueryWrapper<>();
        qw.eq("city_code", cityCode);
        return areaDao.selectList(qw);
    }

    /**
     * 根据城市编号删除区县信息
     * @param areaId
     */
    @Override
    public void deleteAreaByCityId(String areaId) {
        QueryWrapper qw = new QueryWrapper<>();
        qw.eq("area_id", areaId);
        int delete = areaDao.delete(qw);
    }
}
